from django.db import models


#专业表
class MajorTab(models.Model):
    major = models.CharField(max_length=50, verbose_name="专业")

    class Meta:
        verbose_name_plural = "专业"

    def __str__(self):
        return self.major

# 岗位表
class JobTab(models.Model):
    year = models.SmallIntegerField(verbose_name="年份")
    jobCode = models.CharField(max_length=20, verbose_name="职位编码")
    city = models.CharField(max_length=20, verbose_name="行政隶属")
    unit = models.CharField(max_length=100, verbose_name="单位")
    position = models.CharField(max_length=50,verbose_name="岗位")
    recruitNum = models.IntegerField(verbose_name="招聘人数")
    education = models.CharField(max_length=20, verbose_name="学历低限", null=True, blank=True)
    degree = models.CharField(max_length=20, verbose_name="学位低限", null=True, blank=True)
    ask = models.TextField(verbose_name="要求", null=True, blank=True)
    enrollNum = models.IntegerField(verbose_name="报名人数")
    checkNum = models.IntegerField(verbose_name="审核人数")
    checkPassNum = models.IntegerField(verbose_name="审核通过人数")
    payNum = models.IntegerField(verbose_name="缴费人数")

    class Meta:
        verbose_name_plural = "招聘岗位"

    def __str__(self):
        return self.position

# 专业要求表
class JobMajorTab(models.Model):
    job = models.ForeignKey(JobTab, verbose_name="职位", on_delete=models.DO_NOTHING)
    major = models.ForeignKey(MajorTab, verbose_name="专业", on_delete=models.DO_NOTHING)

    class Meta:
        verbose_name_plural = "专业要求信息"

# 考生信息表
class StudentTab(models.Model):
    job = models.ForeignKey(JobTab, verbose_name="职位", on_delete=models.DO_NOTHING)
    name = models.CharField(max_length=50, verbose_name="考生姓名")
    ids = models.CharField(max_length=15, verbose_name="准考证号")
    score = models.FloatField(verbose_name="成绩")
    rank = models.IntegerField(verbose_name="名次")

    class Meta:
        verbose_name_plural = "考生信息"

    def __str__(self):
        return self.name
